package com.yxw.yxnet_cd_center.customer_service.controller;

import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.helper.ResultHelper;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import com.yxw.yxnet_cd_center.customer_service.dto.DataGroupDTO;
import com.yxw.yxnet_cd_center.customer_service.dto.DataGroupQueryDTO;
import com.yxw.yxnet_cd_center.customer_service.dto.DataGroupTagDTO;
import com.yxw.yxnet_cd_center.customer_service.service.IDataGroupService;
import com.yxw.yxnet_cd_center.customer_service.vo.DataGroupVO;
import com.yxw.yxnet_cd_center.customer_service.vo.TagVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 大数据分组Controller控制层处理
 *
 * @author xiexuxin
 * @date 2023-09-25
 */

@Slf4j
@Api(value = "大数据分组", tags = "大数据分组")
@RestController
@Validated
@RequestMapping("/v1/data-group")
public class DataGroupController {

    @Autowired
    private IDataGroupService dataGroupService;

    /**
     * 添加标签
     */
    @ApiOperation("添加标签")
    @PostMapping("/addTag")
    public BaseResult addTag(@RequestBody DataGroupTagDTO tagDTO) {
        dataGroupService.addTag(tagDTO);
        return BaseResult.success();
    }

    /**
     * 添加客户数据
     */
    @ApiOperation("添加客户数据")
    @PostMapping("/addDataGroup")
    public BaseResult addDataGroup(@RequestBody DataGroupDTO dataGroupDTO) {
        dataGroupService.addDataGroup(dataGroupDTO);
        return BaseResult.success();
    }

    /**
     * 删除标签
     */
    @ApiOperation("删除标签")
    @PostMapping("/{id}/deleteTag")
    public BaseResult deleteTag(@PathVariable Long id) {
        dataGroupService.deleteTag(id);
        return BaseResult.success();
    }

    /**
     * 查询标签列表
     */
    @ApiOperation(value = "查询标签列表")
    @GetMapping(value = "/getTagList")
    public BaseResult getTagList() {
        List<TagVO> voList=dataGroupService.tagList();
        return BaseResult.success(voList);
    }

    /**
     *条件查询问题列表
     */
    @ApiOperation(value = "条件查询大数据分组列表")
    @PostMapping(value = "/getDataGroupList")
    public BaseResult<PageVO<DataGroupVO>> getDataGroupList(@RequestBody DataGroupQueryDTO dataGroupQueryDTO) {
        log.info("开始处理【条件查询大数据分组列表】请求,参数:{}",dataGroupQueryDTO);
        PageVO<DataGroupVO> pageVo=dataGroupService.getDataGroupList(dataGroupQueryDTO);
        return ResultHelper.fillWithSuccess(pageVo);
    }

    /**
     *根据标签id查询对应客户
     */
    @ApiOperation(value = "根据标签id查询对应客户")
    @PostMapping(value = "/getDataGroupByTag")
    public BaseResult<PageVO<DataGroupVO>> getDataGroupByTag(@RequestParam("tagId") Long tagId) {
        log.info("开始处理【根据标签id查询对应客户】请求,参数:{}",tagId);
        PageVO<DataGroupVO> pageVo=dataGroupService.getDataGroupByTag(tagId);
        return ResultHelper.fillWithSuccess(pageVo);
    }

    /**
     * 查询问题列表
     */
    @ApiOperation(value = "查询大数据分组列表")
    @PostMapping("/dataGroupList")
    public BaseResult dataGroupList() {
        log.info("开始处理【查询大数据分组列表】请求,无参数");
        List<DataGroupVO> list = dataGroupService.dataGroupList();
        return BaseResult.success(list);
    }
}
